package edu.online.dal;

import edu.online.entity.LessonEntity;
import org.apache.ibatis.jdbc.SQL;

public class LessonEntitySqlProvider {

    public String insertSelective(LessonEntity record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lesson");
        
        if (record.getLessonid() != null) {
            sql.VALUES("LessonID", "#{lessonid,jdbcType=CHAR}");
        }
        
        if (record.getCourseid() != null) {
            sql.VALUES("CourseID", "#{courseid,jdbcType=CHAR}");
        }
        
        if (record.getTeacherid() != null) {
            sql.VALUES("TeacherId", "#{teacherid,jdbcType=CHAR}");
        }
        
        if (record.getFirstday() != null) {
            sql.VALUES("firstDay", "#{firstday,jdbcType=DATE}");
        }
        
        if (record.getPersonnum() != null) {
            sql.VALUES("PersonNum", "#{personnum,jdbcType=SMALLINT}");
        }
        
        if (record.getLeavenum() != null) {
            sql.VALUES("LeaveNum", "#{leavenum,jdbcType=SMALLINT}");
        }
        
        if (record.getSwitchnum() != null) {
            sql.VALUES("SwitchNum", "#{switchnum,jdbcType=SMALLINT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LessonEntity record) {
        SQL sql = new SQL();
        sql.UPDATE("lesson");
        
        if (record.getCourseid() != null) {
            sql.SET("CourseID = #{courseid,jdbcType=CHAR}");
        }
        
        if (record.getTeacherid() != null) {
            sql.SET("TeacherId = #{teacherid,jdbcType=CHAR}");
        }
        
        if (record.getFirstday() != null) {
            sql.SET("firstDay = #{firstday,jdbcType=DATE}");
        }
        
        if (record.getPersonnum() != null) {
            sql.SET("PersonNum = #{personnum,jdbcType=SMALLINT}");
        }
        
        if (record.getLeavenum() != null) {
            sql.SET("LeaveNum = #{leavenum,jdbcType=SMALLINT}");
        }
        
        if (record.getSwitchnum() != null) {
            sql.SET("SwitchNum = #{switchnum,jdbcType=SMALLINT}");
        }
        
        sql.WHERE("LessonID = #{lessonid,jdbcType=CHAR}");
        
        return sql.toString();
    }
}